package com.gohi.main.store.hbm.jdbcMapper;



import java.sql.ResultSet;
import java.sql.SQLException;




import org.apache.commons.lang.StringEscapeUtils;
import org.springframework.jdbc.core.RowMapper;

import com.gohi.main.store.hbm.ShopgooGroupbuy;
import com.gohi.main.store.hbm.ShopgooSpecialoffer;

import com.gohi.main.util.global.GloblConfig;
/**
 * 特卖信息读取
 * @author Administrator
 *
 */
public class SpseciaofferMapper implements RowMapper  {

	@Override
	public Object mapRow(ResultSet rs, int arg1) throws SQLException {
		// TODO Auto-generated method stub
		ShopgooSpecialoffer s =new ShopgooSpecialoffer();

		s.setId(rs.getInt("id"));//主键ID   
		s.setBuyer_count(rs.getInt("buyer_count"));//销售数量
		s.setBuyer_num(rs.getInt("buyer_num"));//购买人数
		s.setName(rs.getString("name"));
		s.setStore_id(rs.getInt("store_id"));
		s.setStore_name(rs.getString("store_name"));
		s.setStart_time(rs.getInt("start_time"));
		s.setEnd_time(rs.getInt("end_time"));
		s.setAddress(rs.getString("address"));
		s.setTelephone(rs.getString("telephone"));
		s.setOriginal_price(rs.getString("original_price"));//原始价格
		s.setPrice(rs.getString("price"));
		s.setIntro(StringEscapeUtils.unescapeHtml(rs.getString("intro")));//描述信息
		//String escaped = StringEscapeUtils.escapeHtml4(stringToEscape);
		//.replace("&lt;", "<").replace("&gt;", ">")
		s.setStore_id(rs.getInt("store_id"));
		s.setHowlong(rs.getInt("howlong"));//项目的总耗时
		s.setComment_count(rs.getInt("comment_count"));
		s.setBusiness_endtime(rs.getInt("business_endtime"));
		
		s.setBusiness_starttime(rs.getInt("business_starttime"));
	//	s.setOriginal_price(rs.getString("original_price"));
		//System.err.println(rs.getString("group_intro"));
		s.setPic(rs.getString("pic"));//轮播图片 逗号隔开
		String sp []= s.getPic().split(",");
		if(sp.length>1){
			s.setPic(GloblConfig.IMG_ITEMS+sp[0]);
			for(String pic : sp ){
				if(!pic.trim().equals("")){
				//	System.err.println(pic);
					s.getPiclist().add(GloblConfig.IMG_ITEMS+ pic.replace("_small.jpg", ""));
				}

			}
		}else{
			s.setPic(GloblConfig.IMG_ITEMS+(sp.length==1?sp[0]:s.getPic()));
			//添加两次轮播图片
			s.getPiclist().add(GloblConfig.IMG_ITEMS+  (sp.length==1?sp[0]:s.getPic().replace("_small.jpg", "")));
			s.getPiclist().add(GloblConfig.IMG_ITEMS+  (sp.length==1?sp[0]:s.getPic().replace("_small.jpg", "")));
		}
		
		//s.setDescription(rs.getString("description"));//描述信息
		return s;
	}




	
}
